<?php

    include '..\Models.php';
    
    //
    // UPLOAD IMAGE
    //

    if(!WebHelper::IsGetKeyNotNull("id"))
    {
	die("Error in the passed parameters.");
    }
    
    $id = WebHelper::GetInt("id");
    $type = WebHelper::GetInt("type");
    
    $fileName = WebHelper::UploadFile("uploadedFile");
    
    
    if($fileName != "")
    {
	DbConnector::Connect();
    
	$place = new Place($id);
        
        if($type == "photo")
        {
            $place->AddPhoto($fileName);	        
        }
        else if($type == "logo")
        {
            $place->AddLogo($fileName);
        }
        
	DbConnector::Disconnect();
    
	WebHelper::Redirect("/Admin/SubmitPlace.php?id=$id");
    }
    
?>

<html>
    <body>
	
        <form enctype="multipart/form-data" action="Upload.php?id=<?= $id ?>&type=<?= $type ?>" method="POST">            
            <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
            Choose a file to upload: <input name="uploadedFile" type="file" /><br />
            <input type="submit" value="Upload File" />
        </form>		
	
    </body>
</html>
   
